﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace NewRen.Models.ViewModel
{
    public class vUser
    {
        public int ID { get; set; }

        /// <summary>
        /// 用户名
        /// </summary>

        public string UserName { get; set; }


        /// <summary>
        /// 密码
        /// </summary>
        public string Password { get; set; }


        /// <summary>
        /// 真是姓名
        /// </summary>
        public string RealName { get; set; }

        /// <summary>
        /// 电话
        /// </summary>
        public string Phone { get; set; }

        /// <summary>
        /// 职业
        /// </summary>
        public string Job { get; set; }

        /// <summary>
        /// 自我描述
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// 城市
        /// </summary>
        public string City { get; set; }

        /// <summary>
        /// 地址
        /// </summary>
        public string Address { get; set; }

        /// <summary>
        /// 区县
        /// </summary>
        public string District { set; get; }

        /// <summary>
        /// 镇
        /// </summary>
        public string Town { set; get; }

        /// <summary>
        /// 邮件
        /// </summary>
        public string Email { get; set; }

        /// <summary>
        /// QQ
        /// </summary>
        public string QQ { get; set; }

        /// <summary>
        /// 性别
        /// </summary>
        public Sex Sex { set; get; }

        /// <summary>
        /// 出生年月日
        /// </summary>
        public DateTime? Birthday { get; set; }

        /// <summary>
        /// 积分
        /// </summary>
        public int? Integration { get; set; }

        /// <summary>
        /// 金钱
        /// </summary>
        public double Money { get; set; }


        /// <summary>
        /// 微博
        /// </summary>
        public string Weibo { get; set; }

        /// <summary>
        /// 微信
        /// </summary>
        public string WhatApp { get; set; }


        /// <summary>
        /// 牛棚名称
        /// </summary>
        public string GroupName { get; set; }

        /// <summary>
        /// 上次登录时间
        /// </summary>
        public DateTime? LastLogin { get; set; }

        /// <summary>
        /// 优先级 用于排名
        /// </summary>
        public int Priority { get; set; }

        /// <summary>
        /// 牛棚，可空
        /// </summary>
        public int? UserGroupID { get; set; }


        /// <summary>
        /// 头像
        /// </summary>
        public byte[] Picture { get; set; }
        /// <summary>
        /// 访问量
        /// </summary>
        public int PV { get; set; }
        /// <summary>
        /// 今日访问量
        /// </summary>
        public int TodayPV { get; set; }

        /// <summary>
        ///赞
        /// </summary>
        public int Ups { get; set; }

        /// <summary>
        /// 踩
        /// </summary>
        public int Downs { get; set; }
        /// /// <summary>
        /// 增加时间
        /// </summary>
        public DateTime? AddTime { get; set; }

        /// <summary>
        /// 是否认证
        /// </summary>
        public bool IsVerified { set; get; }


        public vUser() { }
        public vUser(User user)
        {

            this.ID = user.ID;
            this.UserName = user.UserName;
            this.Password = user.Password;
            this.Email = user.Email;
            this.Phone = user.Phone;
            this.Address = user.Address;
            this.Birthday = user.Birthday;
            this.RealName = user.RealName;
            this.Sex = user.Sex;
            this.QQ = user.QQ;
            this.Money = user.Money;
            this.LastLogin = user.LastLogin;
            this.Job = user.Job;
            this.UserGroupID = user.UserGroupID;
            this.Integration = user.Integration;
            this.WhatApp = user.WhatApp;
            this.Description = user.Description;
            this.AddTime = user.AddTime;
            this.City = user.City;
            this.Picture = user.Picture;
            this.PV = user.PV;
            this.Downs = user.Downs;
            this.Ups = user.Ups;
            this.TodayPV = user.TodayPV;
            this.District = user.District;
            this.Town = user.Town;
            this.IsVerified = user.IsVerified;
            if (UserGroupID.HasValue)
            {
                using (DB db = new DB())
                {
                    this.GroupName = db.UserGroups.Find(UserGroupID).GroupName;
                }
            }

        }


    }
}